package com.dp.log;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class log4jInit extends HttpServlet {
    //protected String config = "/log4j.properties";
    public void init() throws ServletException {
        ServletContext sct = getServletContext();
        System.out.println("[Log4j]: The Root Path: " + sct.getRealPath("/"));
        System.out.println("[Log4j]: log4jInit init start...");
        org.apache.log4j.PropertyConfigurator.configure(sct.getRealPath("/") +
            getServletConfig().getInitParameter("log4j"));
        System.out.println("[Log4j]: log4jInit init over.");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    }
}
